package db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/*Class provide simple interface working with DB*/
public class DbWorker {

    private Connection conn;
    private Statement stat;

    public DbWorker() throws ClassNotFoundException, SQLException {
	Class.forName("org.sqlite.JDBC");
	this.conn = DriverManager.getConnection("jdbc:sqlite:../database.db");
	this.stat = conn.createStatement();

    }

    public void closeConnection() {
	try {
	    this.conn.close();
	} catch (SQLException e) {
	    e.printStackTrace();
	}
    }

    public ResultSet select(String query) {
	try {
	    ResultSet rs = stat.executeQuery(query);

	    return rs;

	} catch (SQLException e) {
	    e.printStackTrace();
	}

	return null;

    }

}